package com.onesports.intelligent.k12.polarlight.service.course;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.onesports.intelligent.k12.polarlight.domain.entity.course.CourseSellPriceRel;
import com.onesports.intelligent.k12.polarlight.domain.vo.course.CourseSellPriceRelVO;
import com.onesports.intelligent.k12.polarlight.mapper.course.CourseSellPriceRelMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Wsy
 **/
@Service
@RequiredArgsConstructor
public class CourseSellPriceRelService extends ServiceImpl<CourseSellPriceRelMapper, CourseSellPriceRel> {

    private final CourseSellPriceRelMapper courseSellPriceRelMapper;


    /**
     * 课程售价分页
     *
     * @param page     分页参数
     * @param courseId 课程id
     * @return IPage<CourseSellPriceRelVO>
     */
    public IPage<CourseSellPriceRelVO> sellPricePage(Page<CourseSellPriceRelVO> page, String courseId) {
        return this.courseSellPriceRelMapper.sellPricePage(page, courseId);
    }

    public CourseSellPriceRel getByCourseIdAndCampusId(String courseId, String campusId, String guidePriceId) {
        return this.getOne(new LambdaQueryWrapper<CourseSellPriceRel>()
                .eq(CourseSellPriceRel::getCourseId, courseId)
                .eq(CourseSellPriceRel::getCampusId, campusId)
                .eq(CourseSellPriceRel::getGuidePriceId, guidePriceId));
    }
}
